<template>
  <el-dialog
    v-model="isShow"
    :title="handle.name + name"
    width="640"
    :close-on-click-modal="false"
    @close="handleClose"
  >
    <el-form class="dialog-form" label-width="100px">
      <el-row :gutter="20">
        <el-col :xs="24">
          <el-form-item label="公会名称：" required>
            <el-input v-model="form.guildName" placeholder="请输入" />
          </el-form-item>
        </el-col>
        <el-col :xs="24">
          <el-form-item label="会长：" required>
            <!-- <el-input v-model="form.price" type="number" placeholder="请输入" /> -->
            <el-select v-model="form.leaderId" placeholder="请选择" clearable style="width:100%">
              <!-- <el-option v-for="(item,index) in optionData.activitieType" :key="index" :label="item.name" :value="item.id" /> -->
               <el-option lable="xxx" value="1"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :xs="24">
          <el-form-item label="描述：">
            <el-input v-model="form.description" type="textarea" placeholder="请输入" />
          </el-form-item>
        </el-col>
        <!-- <el-col :xs="24">
          <el-form-item label="状态：">
            <el-radio-group v-model="form.status">
              <el-radio v-for="(item,index) in optionData.baseType" :key="index" :label="item.id">{{item.name}}</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col> -->
      </el-row>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="isShow = false">取消</el-button>
        <el-button type="primary" :loading="btnLoading" @click="toSubmit">确定</el-button>
      </span>
    </template>
    <my-select ref="refMySelect"/>
  </el-dialog>
</template>

<script setup lang="ts">
import {ElMessage, ElMessageBox} from 'element-plus'
import { ref, reactive, getCurrentInstance, nextTick } from 'vue';
import { useAddEdit } from '/@/assets/compositionFn/addEdit';
const MySelect = defineAsyncComponent(() => import('/@/components/MySelect/index.vue'));
const refMySelect = ref();
const obj = {
  api: '/admin//guilds',
  initForm:{
    guildId: null,
    guildName: null,
    description: null,
    leaderId: null,
  },
};
let {isShow, btnLoading, handle, optionData, form, init, returnInfo, handleClose, submitForm} = useAddEdit(obj);
const emit = defineEmits(['confirm']);
const {proxy} :any = getCurrentInstance();
const prop = defineProps({
  name: {
    type: String,
  }
});
watch(isShow,(newVal, oldVal) => {
  if(newVal){
    //弹窗后的其他操作
    let info = returnInfo();
  }else{
    
  }
});


const verifyForm = ()=>{
  if(!proxy.$verify.null(form.guildName, '请填写卡名称')){
    return false;
  }
  if(!proxy.$verify.null(form.leaderId, '请选择会长')){
    return false;
  }
  return true;
};
const toSubmit = ()=>{
  if(!verifyForm()){
    return;
  }
  submitForm().then(res => {
    emit('confirm');
  });
  
}
defineExpose({
  init,
})
</script>

<style>

</style>